{% extends "base.html" %}
{% import "bootstrap/wtf.html" as wtf %}

{% block title %}标准字段查询
{% endblock %}

{% block content %}
<form action="/web_dim_column" method="post" id="postattr" name="postattr" class="form-inline">
    <input type="hidden" name="csrf_token" value="{{ csrf_token() }}" />
    <div class="form-row align-items-center">
        <div class="form-group col-md-offset-0">
            <label>属性名称</label>
            <input id="column_name" name="column_name" type="text" class="form-control" placeholder="属性名称"/>
        </div>
        <div class="form-group col-md-offset-0">
            <label>数据库类型</label>
            <select id="dbdriver" name="dbdriver" class="form-control" onchange="read_data_type_by_db_driver_js(this.options[this.options.selectedIndex].value, '{{ csrf_token() }}')">
                <option>--数据库驱动类型--</option>
                {% if db_driver_data %}
                    {% for foo in db_driver_data %}
                        <option value="{{ foo.id }}">{{ foo.db_driver_name }}</option>
                    {% endfor %}
                {% endif %}
            </select>
        </div>
        <div class="form-group col-md-offset-0">
            <label>数据类型</label>
            <select id="datatype" name="datatype" class="form-control" ></select>
        </div>
        <div class="form-group col-md-offset-0">
            <label>属性长度</label>
            <input id="data_length" name="data_length" type="number" class="form-control" placeholder="长度"/>
        </div>

    </div>
    <br>
    <div class="form-row">
        <div class="form-group col-md-offset-0">
            <label>属性描述</label>
            <input id="data_describe" name="data_describe" type="text" class="form-control" placeholder="属性描述"/>
        </div>
        <div class="form-group col-md-offset-0">
            <label>属性指标分类</label>
            <select id="columncategory" name="columncategory" class="form-control">
                <option>--属性分类--</option>
                {% if category_data %}
                    {% for foo in category_data %}
                        <option value="{{ foo.id }}">{{ foo.category_name }}</option>
                    {% endfor %}
                {% endif %}
            </select>
        </div>
        <div class="form-group col-md-offset-0">
            <label>属性类型分类</label>
            <select id="type" name="type" class="form-control">
                <option value="1">维度</option>
                <option value="2">度量</option>
            </select>
        </div>

        <div class="form-group col-md-offset-0">
            <label>是否可空</label>
            <select id="is_null" name="is_null" class="form-control">
                <option value="True">可空</option>
                <option value="False">不可空</option>
            </select>
        </div>
        <div class="form-group col-md-offset-0">
            <label>是否主键</label>
            <select id="is_key" name="is_key" class="form-control">
                <option value="False">非主键</option>
                <option value="True">主键</option>
            </select>
        </div>
        <div class="form-group col-md-offset-0">
            <label>默认值</label>
            <input id="defalut_value" name="defalut_value" type="text" class="form-control" placeholder="默认值"/>
        </div>
    </div><br>
    <input type="submit" value="提交" />
</form>
<br>


<table class="table table-bordered">
    <tr>
        <th>属性ID</th>
        <th>属性名称</th>
        <th>属性数据类型</th>
        <th>属性数据类型长度</th>
        <th>属性描述</th>
        <th>属性分类</th>
        <th>属性类别</th>

        <th>是否可空</th>
        <th>是否主键</th>
        <th>默认值</th>
        <th>所有者</th>
    </tr>
        {% for i in json_data.items %}
            <tr>
                <td>{{ i.id }}</td>
                <td>{{ i.column_name }}</td>
                <td>{{ i.data_type_name }}</td>
                <td>{{ i.data_length }}</td>
                <td>{{ i.column_describe }}</td>
                <td>{{ i.category_name }}</td>
                <td>{{ i.type_name }}</td>

                <td>{{ i.is_null }}</td>
                <td>{{ i.is_key }}</td>
                <td>{{ i.defalut_value }}</td>
                <td>{{ i.owner_name }}</td>

                </td>
            </tr>

        {% endfor %}
    </table>
{% if json_data.has_prev %}<a href="{{ url_for('web_dim_column', page = json_data.prev_num) }}"><< 前一页</a>{% else %}<< 前一页{% endif %} |
{% if json_data.has_next %}<a href="{{ url_for('web_dim_column', page = json_data.next_num) }}">后一页 >></a>{% else %}后一页 >>{% endif %}

{% endblock %}

{% block scripts  %}
{{ super() }}
<script src="https://cdn.bootcss.com/jquery/3.3.1/jquery.js"></script>
<script src="/static/js/my_test.js"></script>
{% endblock %}
